﻿using ERPSystem.Common.Domains.Material;
using ERPSystem.Common.DTO;
using ERPSystem.Common.Infrastructure.IRepository;
using MediatR;

namespace BasicInformationCommon.API.BasicInformationCommons.Materiales
{
    public class SupplymannersQueryHandler:IRequestHandler<SupplymannersQueryCommand,Result>
    {
        private readonly IBaseRepository<Supplymanner> supplymannerRepository;

        public SupplymannersQueryHandler(IBaseRepository<Supplymanner> supplymannerRepository)
        {
            this.supplymannerRepository = supplymannerRepository;
        }

        /// <summary>
        /// 供应方式下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<Result> Handle(SupplymannersQueryCommand request, CancellationToken cancellationToken)
        {
           var result = new Result();
            try
            {
                var supplymannersList = await (await supplymannerRepository.GetAll()).ToListAsync();
                result.Data = supplymannersList;
            }
            catch (Exception)
            {

                throw;
            }
            return result;
        }
    }
}
